home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / WWW / Library / Implementation / HTList.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  1.8 KB  |  62 lines

  1. /*  */
  2.  
  3. /*              List object
  4. **
  5. **      The list object is a generic container for storing collections
  6. **      of things in order.
  7. */
  8. #ifndef HTLIST_H
  9. #define HTLIST_H
  10.  
  11. #ifndef HTUTILS_H
  12. #include "HTUtils.h"  /* for BOOL type and PARAMS and ARGS*/
  13. #endif /* HTUTILS_H */
  14.  
  15. typedef struct _HTList HTList;
  16.  
  17. struct _HTList {
  18.   void * object;
  19.   HTList * next;
  20. };
  21.  
  22. #ifdef SHORT_NAMES
  23. #define HTList_new                      HTLiNew
  24. #define HTList_delete                   HTLiDele
  25. #define HTList_addObject                HTLiAdOb
  26. #define HTList_removeObject             HTLiReOb
  27. #define HTList_removeLastObject         HTLiReLa
  28. #define HTList_removeFirstObject        HTLiReFi
  29. #define HTList_count                    HTLiCoun
  30. #define HTList_indexOf                  HTLiInOf
  31. #define HTList_objectAt                 HTLiObAt
  32. #endif
  33.  
  34. extern HTList * HTList_new NOPARAMS;
  35. extern void     HTList_delete PARAMS((HTList *me));
  36.  
  37. /*      Add object to START of list
  38. */
  39. extern void     HTList_addObject PARAMS((HTList *me, void *newObject));
  40.  
  41.  
  42. extern BOOL     HTList_removeObject PARAMS((HTList *me, void *oldObject));
  43. extern void *   HTList_removeLastObject PARAMS((HTList *me));
  44. extern void *   HTList_removeFirstObject PARAMS((HTList *me));
  45. #define         HTList_isEmpty(me) (me ? me->next == NULL : YES)
  46. extern int      HTList_count PARAMS((HTList *me));
  47. extern int      HTList_indexOf PARAMS((HTList *me, void *object));
  48. #define         HTList_lastObject(me) \
  49.   (me && me->next ? me->next->object : NULL)
  50. extern void *   HTList_objectAt PARAMS((HTList *me, int position));
  51.  
  52. /* Fast macro to traverse the list. Call it first with copy of list header :
  53.    it returns the first object and increments the passed list pointer.
  54.    Call it with the same variable until it returns NULL. */
  55. #define HTList_nextObject(me) \
  56.   (me && (me = me->next) ? me->object : NULL)
  57.  
  58. #endif /* HTLIST_H */
  59. /*
  60.  
  61.     */
  62.